import jwt from 'jsonwebtoken'
export const checkAuth = async(req,res,next) => {
    const auth = req.headers['authorization']
    console.log(req.headers);
    if(!auth){
        res.status(401).json({
            code:1,
            msg:"暂无权限"
        })
    }else{
        const token = auth.split(' ')[1]
        const obj = jwt.verify(token, 'buka')
        req.username = obj.data;
        next();
    }
}